package com.changgou.goods.controller;

import com.changgou.entity.QueryPageBean;
import com.changgou.entity.Result;
import com.changgou.entity.StatusCode;
import com.changgou.goods.feign.SpuFeign;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;


/**
 * @author xuchangshuo
 * @date 2020/7/26 10:41
 */
@Controller
@RequestMapping("/find")
public class TrashGoodsController {


    @Autowired
    private SpuFeign spuFeign;

//    //查询回收站商品
//    @RequestMapping("/findReGoods")
//    @ResponseBody
//    public Result findReGoods() {
//        Result<List<Spu>> result = spuFeign.findReGoods();
//        List<Spu> data = result.getData();
//        return new Result(true, StatusCode.OK, "查询成功", data);
//    }

    //回收站
    @RequestMapping("/toTrach")
    public String toTrach() {
        return "trash";
    }

    //恢复回收站商品
    @RequestMapping("/recoverGoods")
    @ResponseBody
    public Result recoverGoods(@RequestParam("id") String id) {
        spuFeign.restore(id);
        return new Result(true, StatusCode.OK, "恢复成功");
    }

   //删除回收站的商品
    @RequestMapping("/delForeverById")
    @ResponseBody
    public Result delForever(@RequestParam("id") String id) {
        spuFeign.realDel(id);
        return new Result(true, StatusCode.OK, "永久删除该商品成功");
    }


    //分页查询回收站商品
    @RequestMapping("/findReGoodsPage")
    @ResponseBody
    public Result findReGoodsPage(@RequestBody QueryPageBean queryPageBean) {
        Result reGoodsPage = spuFeign.findReGoodsPage(queryPageBean);
        return reGoodsPage;
    }


}
